package com.hualan.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.mapper.ExpertiseFieldMapper;
import com.hualan.pojo.ExpertiseField;
import com.hualan.service.ExpertiseFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExpertiseFieldImpl implements ExpertiseFieldService {
    @Autowired
    private ExpertiseFieldMapper expertiseFieldMapper;
    @Override
    public PageInfo<ExpertiseField> selectField(Integer pageNum, Integer pageSize, String fieldName) {
        PageHelper.startPage(pageNum,pageSize);
        List<ExpertiseField> expertiseFields = expertiseFieldMapper.selectByFieldName(fieldName);
        return new PageInfo<>(expertiseFields);
    }

    @Override
    public int insertField(ExpertiseField field) {
        int insert = expertiseFieldMapper.insert(field);
        return insert;
    }

    @Override
    public int deleteField(Long id) {
        return expertiseFieldMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateField(Long id, String fieldName) {
        return expertiseFieldMapper.updateById(id,fieldName);
    }

    @Override
    public int deleteBatch(List<Integer> ids) {
        return expertiseFieldMapper.deleteBatch(ids);
    }
    @Override
    public List<ExpertiseField> find() {
        return expertiseFieldMapper.findAll();
    }
}
